<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" media="screen" href="../../css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="../../layui/css/layui.css">
<link rel="stylesheet" type="text/css" media="screen" href="../../css/common.css">
</head>
<body>
	<div class="col-xs-12 col-sm-12  col-lg-12">
		<form class="form-horizontal" onsubmit="return false" id="form">
			<fieldset>
				<div class="form-group">
					
						<div style="float:left;">
							<button class="btn btn-primary" id="goReturn" onclick="location.href='javascript:history.go(-1)'">返回</button>
						</div>
						<div style="float:right;padding-right:20px;">
							<button class="btn btn-primary hide" id="verifyOk">通过</button>
							<button class="btn btn-primary hide" id="verifyNo">驳回</button>
							<button class="btn btn-primary" id="verifyDesign">审批流程</button>
							<button class="btn btn-primary" id="verifyLogo">审批记录</button>
						</div>
				</div>
				<input type="hidden" id="adId" name="adId">
				<div class="form-group">
					<label class="col-md-2 control-label">素材名称</label>
					<div class="col-md-10">
						<input class="form-control" placeholder="素材名称" type="text"
							name="adName" id="adName" readonly="readonly">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">大小</label>
					<div class="col-md-10">
						<input class="form-control" placeholder="大小" type="text"
							name="adSize" id="adSize" readonly="readonly">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">素材类型</label>
					<div class="col-md-10">
						<input class="form-control" placeholder="素材类型" type="text"
							maxlength="58" name="fileType" id="fileType" readonly="readonly">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">分辨率</label>
					<div class="col-md-10">
						<input class="form-control" placeholder="分辨率" id="resolution"
							name='resolution' readonly="readonly">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">时长</label>
					<div class="col-md-10">
						<input class="form-control" placeholder="时长" id="adSecond"
							name='adSecond' readonly="readonly">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">上传人员</label>
					<div class="col-md-10">
						<input class="form-control" placeholder="上传人员" id="createUserName"
							name='createUserName' readonly="readonly">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">上传时间</label>
					<div class="col-md-10">
						<input class="form-control" placeholder="上传时间" id="createTime"
							name='createTime' readonly="readonly">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">提交审核人</label>
					<div class="col-md-10">
						<input class="form-control" placeholder="提交审核人" id="submitterName"
							name='submitterName' readonly="readonly">
					</div>
				</div>
				<div class="form-group">
					<label class="col-md-2 control-label">文件预览</label>
					<div id="filediv" class="col-md-10"></div>

				</div>

				

			</fieldset>
		</form>
	</div>
	<script type="text/javascript" src="../../js/libs/jquery-2.1.1.min.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript" src="../../js/plugin/bootstrapvalidator/bootstrapValidator.min.js"></script>
	<script type="text/javascript" src="../../layui/layui.js"></script>
	<script type="text/javascript" src="../../js/dict.js"></script>
	<script type="text/javascript">
		var type = GetQueryString("type");//等于1位审核模式、等于0位审核结果详情查看
		var dataStatus = GetQueryString("dataStatus");//等于2为审核中状态
		if(type == null){
			$(".topCheckDiv").addClass("hide");
		}
		if(type == 1){
			$(".topCheckDiv").removeClass("hide");
			if(dataStatus == 2){
				$(".topCheckDiv div .hide").removeClass("hide");
			}
			$(".form-group input,.form-group select").attr("disabled","disabled");
			$(".form-actions").addClass("hide");
		}
		if(type == 0){
			$(".topCheckDiv").removeClass("hide");
			$(".form-actions,#goReturn").addClass("hide");
		}
		layui.use([ 'layer' ], function() {
			var layer = layui.layer;
		});
		$(function(){
			var readId = GetQueryString("readId");
			$("#verifyDesign").click(function(){
				showMaxWindow(urlRootPrefix + "/pages/flowDesign/hccflow/page/design.html?flowId="+readId+"&status=2","审批流程走势图");
			});
			$("#verifyLogo").click(function(){
				showMaxWindow(urlRootPrefix + "/pages/common/verifyLogList.html?readId="+readId,"审批记录");
			});
			//VerifyType只能传入3(通过)/4(驳回)/6(转办)
			$("#verifyOk").click(function(){
				layer.open({
		            type: 1,
		            title:'请确认是否通过该审核?',
		            area : [ '472px', '279px' ], //弹出层宽高
		            content: "<div style='margin-left:10px'>审核说明：</div><div style='display:flex;justify-content:center;'><textarea id='area' style='width:95%;height:150px;'></textarea></div>",
		            btn:['保存','取消'],
		            yes:function (index,layero) {
		                 //获取输入框里面的值
		                var closeContent = top.$("#area").val() || $("#area").val();
		                //console.log(closeContent);
		             	// 在这里提交数据
		                var formdata = {"readId":readId,"verifyType":3,"id":GetQueryString("id"),"rejectReason":closeContent};
						$.ajax({
							type : 'post',
							url : urlRootPrefix + '/msgNoticeReads/read/verify',
							async : false,
							contentType: "application/json; charset=utf-8",  
							data : JSON.stringify(formdata),
							success : function(data) {
								if (!data.success) {
									layer.msg(data.msg, {
										shift : -1,
										time : 3000
									}, function() {
									});
									return;
								}
								layer.msg("审核通过成功", {
									shift : -1,
									time : 1000
								}, function() {
									window.location.href="javascript:history.go(-1)";
									layer.close(index);
									
								});
							}
						});
		                
		                
		            },
		            no:function (index,layero) {
		                 layer.close(index);
		            }
		        });
				
			});
			$("#verifyNo").click(function(){
				layer.open({
		            type: 1,
		            title:'请确认是否驳回该审核?',
		            area : [ '472px', '279px' ], //弹出层宽高
		            content: "<div style='margin-left:10px'>审核说明：</div><div style='display:flex;justify-content:center;'><textarea id='area' style='width:95%;height:150px;'></textarea></div>",
		            btn:['保存','取消'],
		            yes:function (index,layero) {
		                 //获取输入框里面的值
		                var closeContent = top.$("#area").val() || $("#area").val();
		                //console.log(closeContent);
		             	// 在这里提交数据
		                var formdata = {"readId":readId,"verifyType":4,"id":GetQueryString("id"),"rejectReason":closeContent};
						$.ajax({
							type : 'post',
							url : urlRootPrefix + '/msgNoticeReads/read/verify',
							async : false,
							contentType: "application/json; charset=utf-8",  
							data : JSON.stringify(formdata),
							success : function(data) {
								if (!data.success) {
									layer.msg(data.msg, {
										shift : -1,
										time : 3000
									}, function() {
									});
									return;
								}
								layer.msg("审核通过成功", {
									shift : -1,
									time : 1000
								}, function() {
									window.location.href="javascript:history.go(-1)";
									layer.close(index);
								});
							}
						});
		                
		                
		            },
		            no:function (index,layero) {
		                 layer.close(index);
		            }
		        });
			});
		});
		
		initData();

		function initData() {
			var id = GetQueryString("id");
			if (id) {
				$.ajax({
					type : 'get',
					url : urlRootPrefix + '/hdContents/' + id,
					async : false,
					success : function(data) {
						var data = data.data;
						$("#adId").val(data.adId);
						$("#adName").val(data.adName);
						$("#adSize").val(data.adSize < (1024*1024)?eval(data.adSize / 1024).toFixed(2)+"kb": eval(data.adSize / 1024/1024).toFixed(2)+"M");
						$("#fileType").val(data.adTypeName+"-"+data.fileType);
						$("#resolution").val(data.resolution);
						$("#adSecond").val(data.adSecond);
						$("#createUserName").val(data.createUserName);
						$("#createTime").val(data.createTime);
						$("#submitterName").val(data.submitterName);
						var u = "";
						if(data.adTypeId == 1) {
	            			u = "<div>"
	            				+"<a target='_blank' href='"+urlRootPrefix+"/statics"+data.adUrl +"' ><img width='300' src=urlRootPrefix + '/statics"+data.adUrl + "'></img></a>"
	            				+"</div>";
	            		}else if(data.adTypeId == 2) {
	            			u = "<div>"
	            				+"<a target='_blank' href='"+urlRootPrefix+"/statics"+data.adUrl +"' ><video  width='"+(data.resolution.split('*')[0]/1.5)+"' controls='controls' src=urlRootPrefix + '/statics"+data.adUrl + "'></video ></a>"
	            				+"</div>";
	            		} else {
	            			u = "<div style='line-height: 35px;'>"
		        				+"<a target='_blank' href='"+urlRootPrefix+"/statics"+data.adUrl +"' style='display:block;float:left;width:300px;'>点击查看'"+data.fileType+"'文件</a>"
		        				+"</div>";
	            		}
				    	$("#filediv").append(u+"<br/>");
					}
				});
			}
		}

		$('#form').bootstrapValidator();
		
	</script>
</body>
</html>